Skip to content

Fix: Preserve claim_one status update when transaction aborts#14

Draft
kafkasl wants to merge 1 commit into
mainfrom
nested-tx-claim
Draft

Fix: Preserve claim_one status update when transaction aborts#14
kafkasl wants to merge 1 commit into
mainfrom
nested-tx-claim

Conversation

@kafkasl
Copy link
Copy Markdown

@kafkasl kafkasl commented May 29, 2026

Problem

When a SQL error aborted the transaction inside claim_one, the outer transaction was also rolled
back, preventing the job row from being marked as failed.

Solution

  • Wrap the yield p in a nested savepoint transaction (txn.conn.transaction()) so that inner
    aborts don't poison the outer transaction
  • After updating the status, re-fetch the event row so p.evt reflects the final DB state

Testing

Added a test that verifies a job is correctly marked failed when the body raises a SQL error (calling
a non-existent function).

@kafkasl kafkasl added the bug Something isn't working label May 29, 2026
@kafkasl kafkasl requested a review from jph00 May 29, 2026 13:05
@kafkasl kafkasl marked this pull request as draft May 29, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants